﻿<form id="org-account-charge-form" lay-filter="org-account-charge-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <input name="state" type="hidden" value="1"/>
    <div class="layui-form-item">
        <label class="layui-form-label">企业名称</label>
        <div class="layui-input-block">
            <input name="name" placeholder="请输入企业名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" readonly required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">套餐选择</label>
        <div class="layui-input-block">
            <select  lay-filter="org-account-charge-meal-select" name="meal"  lay-verify="required">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">套餐价格</label>
        <div class="layui-input-block">
            <input name="price" placeholder="请先选择套餐" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" readonly required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付方式</label>
        <div class="layui-input-block">
            <select  name="payType"  lay-verify="required">
                <option value = "">请选择支付方式</option>
                <option value = "1">现金</option>
                <option value = "2">刷卡</option>
                <option value = "3">支付宝</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">充值详情</label>
        <div class="layui-input-block">
            <table class="layui-table">
                <colgroup>
                    <col width="25%">
                    <col width="25%">
                    <col width="25%">
                    <col width="25%">
                </colgroup>
                <thead>
                <tr>
                    <th>项目</th>
                    <th>套餐含量</th>
                    <th>当前余量</th>
                    <th>充值后余量</th>
                    <!--<th>签名</th>-->
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>职员数量</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                </tr>
                <tr>
                    <td>客户数量</td>
                    <td>2</td>
                    <td>2</td>
                    <td>2</td>
                </tr>
                <tr>
                    <td>短信次数</td>
                    <td>3</td>
                    <td>3</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>定位次数</td>
                    <td>4</td>
                    <td>4</td>
                    <td>4</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div  style="display: none">
        <button class="layui-btn" lay-filter="org-account-charge-submit" id = "org-account-charge-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'form', 'formSelects', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var formSelects = layui.formSelects;
        var admin = layui.admin;
        form.render("radio","org-account-charge-form");

        admin.reqBackground("org/meal/list",{},function(data){
            admin.putTempData("org-meal-data",data);
            $("#org-account-charge-form [name='meal']").html("");
            $("#org-account-charge-form [name='meal']").append(
                "<option value=''>请选择套餐</option>"
            )
            if(data && data.length){
                for(var i=0;i<data.length;i++){
                    $("#org-account-charge-form [name='meal']").append(
                        "<option value='"+data[i].id+"'>"+data[i].name+"</option>"
                    )
                }
                form.render("select","org-account-charge-form");
            }
        })
        var url = 'org/account/charge';  // 实际项目这里是添加用户的url
        // 回显user数据
        var account = admin.getTempData('org-account-form-obj');
        if (account) {
            form.val('org-account-charge-form', account);
        }
        form.on('select(org-account-charge-meal-select)', function (data) {
            var meals = admin.getTempData("org-meal-data");
            if(data && data.value){
                for(var i=0;i<meals.length;i++){
                    if(meals[i].id == data.value){
                    }
                }
            }
        });
        // 表单提交事件
        form.on('submit(org-account-submit)', function (data) {
            admin.req(url, data.field, function (data) {
                layer.msg("保存成功", {icon: 1});
                admin.putTempData('org-account-formOk', true);  // 操作成功刷新表格
                layer.close(layer.curr_idex)
            },"post");
            return false;
        });
    });
</script>

</body>
</html>